<template>
<view class="contents">
			<uni-card  :title="item.name" thumbnail="" :extra="item.date" :note="item.content" v-for="item in commentList">
				{{item.title}}
			</uni-card>
	 
	</view>
	
		
</template>

<script>
	export default {
		data() {
			return {
				"offset":0 ,
				  "pageIndex": 2,
				  "pageSize": 10,
				commentList:[
					{
					      "id": 1,
					      "title": "学校的篮球场太棒了",
					      "content": "学校的篮球场太棒了，专业级别，自由飞翔！",
					      "date": "2019-07-19",
					      "name": "张三"
					    }
				]

			}
		},
		//开启下拉刷新
		onPullDownRefresh() {
			  this.reload()	
		     setTimeout(()=>{
		     	uni.stopPullDownRefresh()
		     	},3000)
		      
		},
		//上拉加载
		onReachBottom() {
			uni.showLoading({
				title:'加载中···',
				mask:false
			})
			setTimeout(()=>{
				this.loadmore()	
				uni.hideLoading()
				},3000)
		     
		},
		methods: {
			reload(){
			   	uni.request({
			   		url:'http://localhost:8090/freshmenapp/message/list',
			   		method:'POST',
			   		data:{},
			   		success: (res) => {
			   			console.log(res);
			   			
			   			this.commentList=res.data.list
			   		},
					//关闭下拉刷新	
					complete: () => {
						uni.stopPullDownRefresh()
					}
			   	})
			},
			loadmore(){
				this.pageIndex=this.pageIndex+1
				uni.request({
					url:'http://localhost:8090/freshmenapp/message/list',
					method:'POST',
					data:{
						// "offset":this.offset ,
						//   "pageIndex": this.pageIndex,
						//   "pageSize": this.pageSize,
					},
					success: (res) => {
						// console.log(res);
						//将数据拼接在一起
						this.commentList=[...this.commentList,...res.data.list]
					}
				})
			}
			
		},
		onLoad() {
			this.pageIndex=0
			this.loadmore()
		}
	}
</script>

<style>
</style>